/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frames;

import java.awt.Cursor;

/**
 *
 * @author Jesus
 */
public class Principal extends javax.swing.JFrame {

    /**
     * Creates new form Principal
     */
    Inventario v_inventario;
    Servidores v_servidores;
    Mostradores v_mostradores;
    Lavanderia v_lavanderia;
    Ganancias v_ganancias;
    Hilo h = new Hilo();
    Inventario inven = new Inventario(); 
    int horas = 0, minutos = 0, segundos = 0;

    public Principal() {
        initComponents();
        v_inventario = new Inventario();
        v_servidores = new Servidores();
        v_mostradores = new Mostradores();
        v_lavanderia = new Lavanderia();
        v_ganancias = new Ganancias();
        _btnDetener.setVisible(false);
        _btnPausar.setVisible(false);
        _btnReanudar.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        _cronometro = new javax.swing.JLabel();
        _btnIniciar = new javax.swing.JButton();
        _btnPausar = new javax.swing.JButton();
        _btnReanudar = new javax.swing.JButton();
        _btnDetener = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBounds(new java.awt.Rectangle(100, 50, 800, 600));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(800, 600));
        setResizable(false);
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Panel_Mujer2(evt);
            }
        });
        getContentPane().setLayout(null);

        _cronometro.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        _cronometro.setText("00:00:00");
        _cronometro.setOpaque(true);
        getContentPane().add(_cronometro);
        _cronometro.setBounds(50, 30, 150, 44);

        _btnIniciar.setText("Iniciar");
        _btnIniciar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                _btnIniciarMouseClicked(evt);
            }
        });
        getContentPane().add(_btnIniciar);
        _btnIniciar.setBounds(80, 80, 84, 30);

        _btnPausar.setText("Pausar");
        _btnPausar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                _btnPausarMouseClicked(evt);
            }
        });
        getContentPane().add(_btnPausar);
        _btnPausar.setBounds(30, 80, 84, 30);

        _btnReanudar.setText("Reanudar");
        _btnReanudar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        _btnReanudar.setMaximumSize(new java.awt.Dimension(65, 23));
        _btnReanudar.setMinimumSize(new java.awt.Dimension(65, 23));
        _btnReanudar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                _btnReanudarMouseClicked(evt);
            }
        });
        getContentPane().add(_btnReanudar);
        _btnReanudar.setBounds(30, 80, 84, 30);

        _btnDetener.setText("Detener");
        _btnDetener.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                _btnDetenerMouseClicked(evt);
            }
        });
        getContentPane().add(_btnDetener);
        _btnDetener.setBounds(130, 81, 84, 30);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/fondo.png"))); // NOI18N
        jLabel1.setAlignmentY(0.0F);
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 800, 600);

        jPanel1.setAlignmentX(0.0F);
        jPanel1.setAlignmentY(0.0F);
        jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jPanel1.setMaximumSize(new java.awt.Dimension(211, 414));
        jPanel1.setMinimumSize(new java.awt.Dimension(211, 414));
        jPanel1.setPreferredSize(new java.awt.Dimension(211, 414));
        jPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Panel_Vestidor(evt);
            }
        });
        jPanel1.setLayout(null);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/vestidores.jpg"))); // NOI18N
        jLabel2.setAlignmentY(0.0F);
        jPanel1.add(jLabel2);
        jLabel2.setBounds(0, 0, 210, 420);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(17, 130, 211, 414);
        jPanel1.getAccessibleContext().setAccessibleName("");

        jPanel2.setAlignmentX(0.0F);
        jPanel2.setAlignmentY(0.0F);
        jPanel2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Panel_Inventario(evt);
            }
        });
        jPanel2.setLayout(null);

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/inventario.jpg"))); // NOI18N
        jLabel3.setAlignmentY(0.0F);
        jPanel2.add(jLabel3);
        jLabel3.setBounds(0, 0, 516, 198);

        getContentPane().add(jPanel2);
        jPanel2.setBounds(251, 15, 516, 198);

        jPanel3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Panel_Mujer1(evt);
            }
        });
        jPanel3.setLayout(null);

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/servidorM1.jpg"))); // NOI18N
        jLabel4.setAlignmentY(0.0F);
        jPanel3.add(jLabel4);
        jLabel4.setBounds(0, 0, 80, 72);

        getContentPane().add(jPanel3);
        jPanel3.setBounds(277, 259, 80, 72);

        jPanel4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Panel_Hombre1(evt);
            }
        });
        jPanel4.setLayout(null);

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/servidorH1.jpg"))); // NOI18N
        jLabel5.setAlignmentY(0.0F);
        jPanel4.add(jLabel5);
        jLabel5.setBounds(0, 0, 87, 76);

        getContentPane().add(jPanel4);
        jPanel4.setBounds(380, 248, 87, 76);

        jPanel5.setLayout(null);

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/servidorM2.jpg"))); // NOI18N
        jLabel6.setAlignmentY(0.0F);
        jPanel5.add(jLabel6);
        jLabel6.setBounds(0, 0, 78, 78);

        getContentPane().add(jPanel5);
        jPanel5.setBounds(479, 258, 78, 78);

        jPanel6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Panel_Hombre2(evt);
            }
        });
        jPanel6.setLayout(null);

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/servidorH2.jpg"))); // NOI18N
        jLabel7.setAlignmentY(0.0F);
        jPanel6.add(jLabel7);
        jLabel7.setBounds(0, 0, 81, 70);

        getContentPane().add(jPanel6);
        jPanel6.setBounds(592, 255, 81, 70);

        jPanel7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Panel_Entrega(evt);
            }
        });
        jPanel7.setLayout(null);

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/servidorE1.jpg"))); // NOI18N
        jLabel8.setAlignmentY(0.0F);
        jPanel7.add(jLabel8);
        jLabel8.setBounds(0, 0, 76, 76);

        getContentPane().add(jPanel7);
        jPanel7.setBounds(690, 253, 76, 76);

        jPanel8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Panel_Ganancias(evt);
            }
        });
        jPanel8.setLayout(null);

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/imagenes/imagenes/ganancias.jpg"))); // NOI18N
        jPanel8.add(jLabel9);
        jLabel9.setBounds(0, 0, 61, 42);

        getContentPane().add(jPanel8);
        jPanel8.setBounds(641, 341, 61, 42);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void _btnIniciarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event__btnIniciarMouseClicked
        // TODO add your handling code here:
        if(!h.isAlive())
            h.start();
        _btnDetener.setVisible(true);
        _btnPausar.setVisible(true);
        _btnIniciar.setVisible(false);
    }//GEN-LAST:event__btnIniciarMouseClicked

    private void Panel_Vestidor(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Panel_Vestidor
        // TODO add your handling code here:
        System.out.println("click vestidores");
    }//GEN-LAST:event_Panel_Vestidor

    private void Panel_Inventario(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Panel_Inventario
        // TODO add your handling code here:
        System.out.println("click inventario");
    }//GEN-LAST:event_Panel_Inventario

    private void Panel_Mujer1(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Panel_Mujer1
        // TODO add your handling code here:
        System.out.println("click servidor mujer 1");
    }//GEN-LAST:event_Panel_Mujer1

    private void Panel_Hombre1(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Panel_Hombre1
        // TODO add your handling code here:
        System.out.println("click servidor hombre 1");
    }//GEN-LAST:event_Panel_Hombre1

    private void Panel_Mujer2(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Panel_Mujer2
        // TODO add your handling code here:
        System.out.println("click servidor mujer 2");
    }//GEN-LAST:event_Panel_Mujer2

    private void Panel_Hombre2(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Panel_Hombre2
        // TODO add your handling code here:
        System.out.println("click servidor hombre 2");
    }//GEN-LAST:event_Panel_Hombre2

    private void Panel_Entrega(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Panel_Entrega
        // TODO add your handling code here:
        System.out.println("click servidor de entregas");
    }//GEN-LAST:event_Panel_Entrega

    private void Panel_Ganancias(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Panel_Ganancias
        // TODO add your handling code here:
        System.out.println("click ganancias");
    }//GEN-LAST:event_Panel_Ganancias

    private void _btnDetenerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event__btnDetenerMouseClicked
        // TODO add your handling code here:
        _btnDetener.setVisible(false);
        _btnIniciar.setVisible(false);
        _btnPausar.setVisible(false);
        _btnReanudar.setVisible(false);
        h.stop();
    }//GEN-LAST:event__btnDetenerMouseClicked

    private void _btnPausarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event__btnPausarMouseClicked
        // TODO add your handling code here:
        _btnReanudar.setVisible(true);
        _btnPausar.setVisible(false);
        h.suspend();
    }//GEN-LAST:event__btnPausarMouseClicked

    private void _btnReanudarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event__btnReanudarMouseClicked
        // TODO add your handling code here:
        _btnPausar.setVisible(true);
        _btnReanudar.setVisible(false);
        h.resume();
    }//GEN-LAST:event__btnReanudarMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton _btnDetener;
    private javax.swing.JButton _btnIniciar;
    private javax.swing.JButton _btnPausar;
    private javax.swing.JButton _btnReanudar;
    private javax.swing.JLabel _cronometro;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    // End of variables declaration//GEN-END:variables

    private class Hilo extends Thread {

        @Override
        //run que lleva el tiempo de la simulación
        public void run() {
            for (horas = 0; horas < 24; horas++) {
                for (minutos = 0; minutos < 60; minutos++) {
                    for (segundos = 0; segundos < 60; segundos++) {

                        if (horas >= 0 && horas <= 9) {
                            if (minutos >= 0 && minutos <= 9) {
                                if (segundos >= 0 && segundos <= 9) {
                                    _cronometro.setText("0" + horas + ":0" + minutos + ":0" + segundos);
                                } else {
                                    _cronometro.setText("0" + horas + ":0" + minutos + ":" + segundos);
                                }
                            } else {
                                if (segundos >= 0 && segundos <= 9) {
                                    _cronometro.setText("0" + horas + ":" + minutos + ":0" + segundos);
                                } else {
                                    _cronometro.setText("0" + horas + ":" + minutos + ":" + segundos);
                                }
                            }
                        } else {
                            if (minutos >= 0 && minutos <= 9) {
                                if (segundos >= 0 && segundos <= 9) {
                                    _cronometro.setText(horas + ":0" + minutos + ":0" + segundos);
                                } else {
                                    _cronometro.setText(horas + ":0" + minutos + ":" + segundos);
                                }
                            } else {
                                if (segundos >= 0 && segundos <= 9) {
                                    _cronometro.setText(horas + ":" + minutos + ":0" + segundos);
                                } else {
                                    _cronometro.setText(horas + ":" + minutos + ":" + segundos);
                                }
                            }
                        }
                        try {
                            Thread.sleep(1);
                        } catch (InterruptedException ex) {
                            System.out.println("Error en los segundos");
                        }
                        if (horas == 23 && minutos == 59 && segundos == 59) {
                            horas = minutos = segundos = 0;
                        }
                    }
                }
            }
        }
    }
}
